import java.util.ArrayList;
public class Solution {
    public ArrayList<ArrayList<Integer> > FindContinuousSequence(int sum) {
       
        // 穷举
        /*
        ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>();

        for (int i = 1; i <= sum/2; i++) {
            ArrayList<Integer> temp = new ArrayList<>();
            int sumTemp = 0;
            for (int j = i; ; j++) {
                sumTemp += j;
                temp.add(j);
                if (sumTemp == sum) {
                    res.add(temp);
                    break;
                }
                else if (sumTemp > sum) {
                    break;
                }
            }
        }

        return res;
        */

        // 滑动窗口
        ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>();

        int left = 1;
        int right = 0;

        int tempSum = 0;

        while (left <= sum / 2) {
            if (tempSum == sum) {
                ArrayList<Integer> temp = new ArrayList<>();
                for (int i = left; i <= right; i++) {
                    temp.add(i);
                }
                res.add(temp);

                tempSum -= left;
                left++;
            }
            else if (tempSum > sum) {
                tempSum -= left;
                left++;
            }
            else {
                right++;
                tempSum += right;
            }
            System.out.println(tempSum);
        }

        return res;

    }
}